package com.verifone.tony.dagger2test;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

import javax.inject.Inject;

//http://hjxandhmr.github.io/2016/05/23/Android-Dagger2-DI/
public class MainActivity extends AppCompatActivity {
    private static final String TAG = "MainActivity";

    private ActivityComponent activityComponent;

    @Inject //标记需要被注入的对象
    UserModel userModel;

    @Inject
    Shoe shoe;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        activityComponent = DaggerActivityComponent.builder().activityModule(new ActivityModule()).build();
        activityComponent.inject(this);

        ((TextView) findViewById(R.id.textView)).
                setText("ID:" + userModel.getId() + " Name: " + userModel.getName()
                        + "  Gender: " + userModel.getGender() + shoe.toString());

    }
}
